package com.djx.service.impl;

import com.djx.dao.OrderDao;
import com.djx.entity.EasyExcelOrderGoodsVo;
import com.djx.entity.Order;
import com.djx.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;

    @Override
    public List<Order> findAll() {

        return orderDao.findAll();
    }

    @Override
    public List<EasyExcelOrderGoodsVo> findEasyExcelOrderGoods() {
        List<EasyExcelOrderGoodsVo> easyExcelOrderGoods = orderDao.findEasyExcelOrderGoods();
        for (EasyExcelOrderGoodsVo easyExcelOrderGood : easyExcelOrderGoods) {
            if (0 == easyExcelOrderGood.getOrderStatu()) {
                easyExcelOrderGood.setOrderStatus("待支付");
            } else if (1 == easyExcelOrderGood.getOrderStatu()) {
                easyExcelOrderGood.setOrderStatus("待发货");
            } else if (2 == easyExcelOrderGood.getOrderStatu()) {
                easyExcelOrderGood.setOrderStatus("待收货");
            } else if (3 == easyExcelOrderGood.getOrderStatu()) {
                easyExcelOrderGood.setOrderStatus("确认收货");
            } else if (4 == easyExcelOrderGood.getOrderStatu()) {
                easyExcelOrderGood.setOrderStatus("订单完成");
            } else if (5 == easyExcelOrderGood.getOrderStatu()) {
                easyExcelOrderGood.setOrderStatus("订单关闭");
            }

        }


        return easyExcelOrderGoods;
    }

}
